<?php
define('FPDF_FONTPATH','font/');
require('fpdf/fpdf.php');
include ("../Login/ModelConexion.php");
$cedest = $_REQUEST['id'];
class PDF extends FPDF
{
//Page header
function Header()
{
    //Logo
   $this->Image('../../Logotipo/LogoAgro.png',175,8,25);
   
    //Arial bold 15
  /*  $this->SetFont('Arial','B',13);
    //Move to the right
    $this->Cell(40);
    //Title
    $this->SetMargins(30,0);
    $this->Cell(10,25, '',0,1,'C');
    $this->Cell(0,5, 'Ministerio de Educacion Publica',0,1,'L');
    $this->Cell(0,5, 'Colegio Tecnico Profesional de Nicoya',0,1,'L');
    $this->Cell(0,5, 'Modalidad Nocturana',0,1,'L');
    $this->Cell(0,5, 'Departamento de Orientacion',0,1,'L');
    $this->Cell(0,20, 'Cuestionario Inicial',0,1,'C');
    //Line break*/
 
}

//Page footer
function Footer()
{
    //Position at 1.5 cm from bottom
    
    $this->SetY(-10);
    //Arial italic 8
    $this->SetFont('Arial','I',10);
    //Page number
    
    $fechayHora = date("d-m-Y");

    $hora=time();
    $this->Image('../../Logotipo/SIPRESTV1_TRANS.png',175,260,25);


}
}
//Instanciation of inherited class
    //Line break

$pdf = new PDF('P','mm','Letter');
$pdf->SetMargins(30,0);

$pdf->AliasNbPages();
$pdf->AddPage();

$pdf->SetFont('Arial','B',13);
$pdf->Cell(10,20, '',0,1,'C');
$pdf->Cell(10,20, '',0,1,'C');
    $pdf->Cell(0,5, 'Ministerio de Educacion Publica',0,1,'C');
    $pdf->Cell(0,5, 'Colegio Tecnico Profesional de Nicoya',0,1,'C');
    $pdf->Cell(0,5, 'Modalidad Nocturana',0,1,'C');
    $pdf->Cell(0,5, 'Departamento de Orientacion',0,1,'C');
    $pdf->Cell(0,20, 'Cuestionario Inicial',0,1,'C');
$pdf->SetFont('Times','',12);    
$pdf->Cell(0,5,"fecha:"."     ". date("d-m-Y"),0,1,'L');
  $pdf->SetFont('Arial','B',13);
$pdf->Cell(90,10,"Datos Personales",0,1,'L');
$pdf->SetFont('Times','',12); 
$pdf->Cell(90,5,"Nombre"."                                        "."Primer Apellido"."                        "."Segundo Apellido",0,1,'L');
 
$objeto = new Conexion(); 
     $rec = $objeto->Consulta("
      SELECT NOES,A1ES,A2ES FROM tb_est WHERE IDES = $cedest
        ");

      while ($row = mysql_fetch_array($rec)) {

       $pdf->Cell(120,5,$row['NOES'],0,1,'L');
       $pdf->Cell(130,-5,$row['A1ES'],0,1,'C');
       $pdf->Cell(231,5,$row['A2ES'],0,1,'C');
      /*  $pdf->Cell(90,5,$row['nombre'],1,1,'C');*/
      }
        $pdf->Cell(10,10, '',0,1,'C');
$pdf->Cell(90,5,"Cedula"."                                          "."Sexo"."                                          "."Fecha Nacimiento",0,1,'L');
 
$objeto = new Conexion(); 
     $rec = $objeto->Consulta("
      SELECT IDES,SEES,FEES FROM tb_est WHERE IDES = $cedest
        ");

      while ($row = mysql_fetch_array($rec)) {
      // $pdf->Cell(120,5,$row['IDES']."                                     ".$row['SEES']."                          ".$row['FEES'],0,1,'L');
       $pdf->Cell(120,5,$row['IDES'],0,1,'L');
       $pdf->Cell(140,-5,$row['SEES'],0,1,'C');
       $pdf->Cell(241,5,$row['FEES'],0,1,'C');
      }

       $pdf->Cell(10,10, '',0,1,'C');
$pdf->Cell(90,5,"Nacionalidad"."                                "."Tel Habitacion"."                          "."Tel Celular",0,1,'L');
 
$objeto = new Conexion(); 
     $rec = $objeto->Consulta("
      SELECT NAES,TEES,CEES FROM tb_est WHERE IDES = $cedest
        ");

      while ($row = mysql_fetch_array($rec)) {
    //   $pdf->Cell(120,5,$row['NAES']."                  ".$row['TEES']."                                  ".$row['CEES'],0,1,'L');
       $pdf->Cell(120,5,$row['NAES'],0,1,'L');
       $pdf->Cell(132,-5,$row['TEES'],0,1,'C');
       $pdf->Cell(238,5,$row['CEES'],0,1,'C');
      }

   $pdf->Cell(10,10, '',0,1,'C');//espacio
$pdf->Cell(90,5,"Direccion: "."                                                                                      "."Es Repitente: "."                         "."",0,1,'L');
   $pdf->Cell(10,10, '',0,1,'C');//espacio
$pdf->Cell(90,10,"Institucion de Procedencia "."                                                            "."Especialidad",0,1,'L');
   $pdf->Cell(10,10, '',0,1,'C');//espacio
$pdf->Cell(90,5,"",0,1,'L');

$objeto = new Conexion(); 
     $rec = $objeto->Consulta("
      SELECT DIES,PRES,tb_especialidad.NOES,REES FROM tb_est,tb_especialidad WHERE tb_est.COES = tb_especialidad.COES AND IDES = $cedest
        ");

      while ($row = mysql_fetch_array($rec)) {
    //   $pdf->Cell(120,5,$row['NAES']."                  ".$row['TEES']."                                  ".$row['CEES'],0,1,'L');
       $pdf->Cell(120,-65,$row['DIES'],0,1,'L');
       $pdf->Cell(228,65,$row['REES'],0,1,'C');
       $pdf->Cell(231,-30,$row['NOES'],0,1,'C');
       $pdf->Cell(12,30,$row['PRES'],0,1,'C');
       

     
      }

   $pdf->Cell(10,0, '',0,1,'C');//espacio
$pdf->Cell(90,-5,"Matricula Condicionada "."                                                                "."Situaciones Personales",0,1,'L');
$objeto = new Conexion(); 
     $rec = $objeto->Consulta("
      SELECT MAES,SIES FROM tb_est WHERE IDES = $cedest
        ");

      while ($row = mysql_fetch_array($rec)) {
    //   $pdf->Cell(120,5,$row['NAES']."                  ".$row['TEES']."                                  ".$row['CEES'],0,1,'L');
       $pdf->Cell(120,15,$row['MAES'],0,1,'L');
       $pdf->Cell(228,-15,$row['SIES'],0,1,'C');
      } 


         $pdf->Cell(10,0, '',0,1,'C');//espacio
$pdf->Cell(90,33,"Enfermedad",0,1,'L');
$objeto = new Conexion(); 
     $rec = $objeto->Consulta("
      SELECT ENES FROM tb_est WHERE IDES = $cedest
        ");

      while ($row = mysql_fetch_array($rec)) {
    //   $pdf->Cell(120,5,$row['NAES']."                  ".$row['TEES']."                                  ".$row['CEES'],0,1,'L');
       $pdf->Cell(120,-20,$row['ENES'],0,1,'L');
      }  

         $pdf->Cell(10,0, '',0,1,'C');//espacio
$pdf->Cell(90,40,"En caso de Emergencia llamar a ",0,1,'L');
$objeto = new Conexion(); 
     $rec = $objeto->Consulta("
      SELECT IDEN,NOEN,TEEN FROM tb_est WHERE IDES = $cedest
        ");

      while ($row = mysql_fetch_array($rec)) {
    //   $pdf->Cell(120,5,$row['NAES']."                  ".$row['TEES']."                                  ".$row['CEES'],0,1,'L');
       $pdf->Cell(120,-20,$row['IDEN']."  ".$row['NOEN']."  ".$row['TEEN'],0,1,'L');
      }  

      $pdf->addPage();

         $pdf->Cell(10,0, '',0,1,'C');//espacio
         $pdf->SetFont('Arial','B',13);
         $pdf->Cell(10,20, '',0,1,'C');

                 $pdf->SetMargins(10,0);
$pdf->Cell(90,33,"DATOS DEL NUCLEO FAMILIAR",0,1,'L');
        $pdf->SetFont('Times','',10);

        $pdf->Cell(65,5,'Nombre Completo',1,0,'C');
        $pdf->Cell(25,5,'Cedula',1,0,'C');
        $pdf->Cell(15,5,'Edad',1,0,'C');
        $pdf->Cell(25,5,'Parentesco',1,0,'C');
        $pdf->Cell(20,5,'Escolaridad',1,0,'C');
        $pdf->Cell(25,5,'Ocupacion',1,0,'C');
        $pdf->Cell(25,5,'Ingreso',1,1,'C');
        
 $objeto = new Conexion(); 
     $rec = $objeto->Consulta("
      SELECT * FROM tb_gf WHERE IDES = $cedest 
        ");

      while ($row = mysql_fetch_array($rec)) {
        $pdf->Cell(65,5,$row['NOGF'],1,0,'C');
        $pdf->Cell(25,5,$row['IDGF'],1,0,'C');
        $pdf->Cell(15,5,$row['EDGF'],1,0,'C');
        $pdf->Cell(25,5,$row['PAGF'],1,0,'C');
        $pdf->Cell(20,5,$row['ESGF'],1,0,'C');
        $pdf->Cell(25,5,$row['OCGF'],1,0,'C');
        $pdf->Cell(25,5,$row['INGF'],1,1,'C');

      }

         $pdf->Cell(10,0, '',0,1,'C');//espacio
         $pdf->SetFont('Arial','',12);
                 $pdf->SetMargins(50,0);
$pdf->Cell(200,33,"Responsables y Annos en que ha sido beneficiado(a) de la beca de avancemos",0,1,'C');
        $pdf->SetFont('Times','',10);

        $pdf->Cell(25,5,'Anno',1,0,'C');
        $pdf->Cell(30,5,'Cedula Encargado',1,0,'C');
        $pdf->Cell(65,5,'Nombre Encargado',1,1,'C');
 
        
 $objeto = new Conexion(); 
     $rec = $objeto->Consulta("
SELECT
  `IDES`,
  `ANBE`,
  `IDFE`,
  `NOFE`,
  `OBSE`
FROM `siprest`.`tb_beca`
WHERE IDES = $cedest
        ");

      while ($row = mysql_fetch_array($rec)) {
        $pdf->Cell(25,5,$row['ANBE'],1,0,'C');
        $pdf->Cell(30,5,$row['IDFE'],1,0,'C');
        $pdf->Cell(65,5,$row['NOFE'],1,1,'C');


      }

   $pdf->SetFont('Times','',12);
                 $pdf->SetMargins(20,0);
$pdf->Cell(90,33,"Observaciones",0,1,'L');
 $objeto = new Conexion(); 
     $rec = $objeto->Consulta("
SELECT
  `IDES`,
  `ANBE`,
  `IDFE`,
  `NOFE`,
  `OBSE`
FROM `siprest`.`tb_beca`
WHERE IDES = $cedest
        ");

      while ($row = mysql_fetch_array($rec)) {
        $pdf->Cell(70,-5,$row['OBSE'],0,1,'C');


      }

         $pdf->SetFont('Times','',12);
                 $pdf->SetMargins(30,0);
$pdf->Cell(120,100,"Firma del Orientador: _______________________",0,1,'C');

$pdf->Output();
?>